# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Ionut Biru <ibiru@archlinux.org>

pkgbase=pygobject
pkgname=(
  python-gobject
  python-gobject-docs
)
pkgver=3.46.0
pkgrel=1
pkgdesc="Python bindings for GLib/GObject/GIO/GTK"
url="https://wiki.gnome.org/Projects/PyGObject"
arch=(loong64 x86_64)
license=(LGPL)
depends=(
  gobject-introspection-runtime
  python
)
makedepends=(
  git
  gobject-introspection
  meson
  python-cairo
  python-sphinx
  python-sphinx_rtd_theme
)
makedepends+=(
  gtk3
  python-pytest
  xorg-server-xvfb
)
optdepends=('cairo: Cairo bindings')
_commit=b5b3fb1fcdbf539dd0cc04120ee4a8e81bce403c  # tags/3.46.0^0
source=(
  "git+https://gitlab.gnome.org/GNOME/pygobject.git#commit=$_commit"
)
b2sums=('SKIP')

pkgver() {
  cd pygobject
  git describe --tags | sed 's/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
  cd pygobject
}

build() {
  arch-meson pygobject build
  meson compile -C build
}

check() {
  PYTEST_ADDOPTS="-v" PYGI_TEST_VERBOSE=1 \
    xvfb-run -s '-nolisten local' \
    meson test -C build --print-errorlogs
}

package_python-gobject() {
  provides=("pygobject-devel=$pkgver")
  conflicts=(pygobject-devel)
  replaces=('pygobject-devel<=3.36.1-1')

  meson install -C build --destdir "$pkgdir"
  python -m compileall -d /usr/lib "$pkgdir/usr/lib"
  python -O -m compileall -d /usr/lib "$pkgdir/usr/lib"
}

package_python-gobject-docs() {
  pkgdesc="Developer documentation for PyGObject"
  depends=()
  optdepends=()

  python -m sphinx -b html pygobject/docs "$pkgdir/usr/share/doc/pygobject/html"
  rm -r "$pkgdir/usr/share/doc/pygobject/html/.doctrees"
}


# vim:set sw=2 sts=-1 et:
